function xn = normalize(x,base)
  % normalize the vector

  if nargin < 2
    base = 10;
  end

  x = real(x);
  carry = 0;
  xn = [];
  for k=1:length(x)
    digit = mod(x(k)+carry, base);
    xn = [xn digit];
    carry = floor(x(k)/base);
  end
  xn = [xn carry];  
